package com.itsu.integration.service.impl;

import com.alibaba.fastjson.JSON;
import com.itsu.integration.factory.GetCountryResponse;
import com.itsu.integration.service.ReceiveService;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

/**
 * 异步模式/无响应，只做消息处理,不推荐使用
 * @author suben
 * @date 2020/4/29 18:25
 */
@Service
public class ReceiveServiceImpl implements ReceiveService {

    @Override
    public void hello(String msg) {
        System.err.println("receive: hello() = " + msg);
    }

    @Override
    public void receive(GetCountryResponse response) {
        System.err.println("receive: receive() = " + JSON.toJSONString(response));
//        return response;
    }


    public Message reply(Message message) {
        System.err.println("reply " + JSON.toJSONString(message));
        return MessageBuilder.withPayload(message).build();
    }

}
